#pragma once
#include "StdAfx.h"
class TextureDesc
	:public GameResourceDesc
{
public:
	TextureDesc()
	{
		MagFilter=GL_LINEAR;
		MinFilter=GL_LINEAR_MIPMAP_LINEAR;
		Format=GL_RGBA;
		InternalFormat=GL_RGBA8;
		bGenerateMipmaps=true;
		bDepthCompare=false;
		Width=Height=TEXTURE_RESOLUTION;
		Target=GL_TEXTURE_2D;
		Type=GL_UNSIGNED_BYTE;
	};
	GLenum MagFilter, MinFilter, Format, Type, Target;
	GLuint InternalFormat;
	//use only resolutions that are powers of 2
	unsigned int Width, Height;
	bool bGenerateMipmaps, bDepthCompare;
};

class Texture :
	public GameResource
{
public:
	explicit Texture(GameResourceDesc &desc):GameResource(desc){};
	Texture(TextureDesc&);
	~Texture(void);
	//use only resolutions that are powers of 2
	bool bGenerateMipmaps, bDepthCompare;

	virtual void LoadFromFile();
	virtual void SaveToFile();

	GLuint GetID();
	void Bind();
	void Unbind();
	void StoreFrame(unsigned int originx, unsigned int originy, unsigned int width, unsigned int height, unsigned int face_id=0, unsigned int level=0);
	bool IsCubeMap();
	void GenerateMipMaps();
	void Resize(int width, int height);
	Vec2 GetDimensions();
private:
	//OpenGL texture ID
	GLuint TextureID;
	unsigned int Width, Height;
	GLenum MagFilter, MinFilter, Format, Type, Target;
	GLuint InternalFormat;

};

